package com.cetc39.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.cetc39.bean.LifeCycle;
import com.cetc39.bean.Subcycle;
import com.cetc39.dao.SubcycleDao;

public class SubcycleDaoImpl extends HibernateDaoSupport implements SubcycleDao {

	@Override
	public void save(Subcycle sc) {
		this.getHibernateTemplate().save(sc);
	}

	@Override
	public void update(Subcycle sc) {
		this.getHibernateTemplate().saveOrUpdate(sc);
	}

	@Override
	public List<?> findAll() {
		return this.getHibernateTemplate().find("FROM Subcycle"); 
	}


	@Override
	public void delete(int id) {
		Subcycle sc = this.getHibernateTemplate().get(Subcycle.class, id);
		this.getHibernateTemplate().delete(sc);
	}

	@Override
	public Subcycle findById(int id) {
		return this.getHibernateTemplate().get(Subcycle.class, id);
	}

	@Override
	public List<?> findByName(String name) {
		return this.getHibernateTemplate().find("FROM Subcycle WHERE name_subcycle=?",  new Object[]{name});
	}

}
